package com.moleq.util;

public class RoundUtil {

	public static double toRound(double val, double downVal, double upVal, double toVal) {
		double result = 0;

		double x = val % toVal;
		x = BigDecmialTool.round(x, 2);
		double y = val - x;
		if (x >= upVal) {
			result = toVal;
		} else if (x <= downVal) {
			result = 0;
		} else {
			result = x;
		}
		return result + y;

	}

}
